#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>

int main()
{
	pid_t id=fork();
	if(id==0)
	{
		int cnt=10;
		while(cnt--)
		{
			printf("I am a child...PID:%d,PPID:%d\n",getpid(),getppid());
			sleep(2);
		}
	}
	int status=0;
	pid_t ret=wait(&status);
	if(ret>0)
	{
		printf("wait child success...\n");
		if(WIFEXITED(status))
		{
			printf("exit code:%d\n",WEXITSTATUS(status));	
		}
	}
	sleep(2);

	return 0;
}
